<?php
/**
 * 手机端分类图片设置
 *
 *
 *
 ** 本系统由网店运维 shop w w i.com提供
 */

//use Shopnc\Tpl;

defined('InShopNC') or exit('Access Invalid!');
class mb_slidersControl extends SystemControl{
    public function __construct(){
        parent::__construct();
        Language::read('mobile');
    }

    public function indexOp() {
        $this->mb_sliders_listOp();
    }
    /**
     *
     */
    public function mb_sliders_listOp(){
        $lang   = Language::getLangContent();
        $model_link = Model('mb_sliders');
        /**
         * 删除
         */
        if ($_POST['form_submit'] == 'ok'){
            if (is_array($_POST['del_id']) && !empty($_POST['del_id'])){
                foreach ($_POST['del_id'] as $k => $v){
                    /**
                     * 删除图片
                     */
                    $v = intval($v);
                    $tmp = $model_link->getOneLink($v);
                    if (!empty($tmp['gc_thumb'])){
                        @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$tmp['gc_thumb']);
                    }
                    unset($tmp);
                    $model_link->del($v);
                }
                showMessage($lang['link_index_del_succ']);
            }else {
                showMessage($lang['link_index_choose_del']);
            }
        }

        $link_list = $model_link->getLinkList(array());
        /**
         * 整理图片链接
         */
        if (is_array($link_list)){
            foreach ($link_list as $k => $v){
                if (!empty($v['gc_thumb'])){
                    $link_list[$k]['gc_thumb'] = UPLOAD_SITE_URL.'/'.ATTACH_MOBILE.'/sliders'.'/'.$v['gc_thumb'];
                }
            }
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        $this->show_menu('mb_sliders_list');

        Tpl::output('link_list',$link_list);
        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_sliders.list');
    }

    /**
     * 删除
     */
    public function mb_sliders_delOp(){
        $lang   = Language::getLangContent();
        if (intval($_GET['gc_id']) > 0){
            $model_link = Model('mb_sliders');

            /**
             * 删除图片
             */
            $tmp = $model_link->getOneLink(intval($_GET['gc_id']));
            if (!empty($tmp['gc_thumb'])){
                @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$tmp['gc_thumb']);
            }
            $model_link->del($tmp['gc_id']);
            showMessage($lang['link_index_del_succ'],'index.php?act=mb_sliders&op=mb_sliders_list');
        }else {
            showMessage($lang['link_index_choose_del'],'index.php?act=mb_sliders&op=mb_sliders_list');
        }
    }

    /**
     * 添加
     */
    public function mb_sliders_addOp(){

        $lang   = Language::getLangContent();
        $model_link = Model('mb_sliders');

        if ($_POST['form_submit'] == 'ok'){
            $category = $model_link->getOneLink(intval($_POST['link_sliders']));
            if (!empty($category)){
                showMessage($lang['link_add_sliders_exist']);
            }

            /**
             * 上传图片
             */
            if ($_FILES['link_pic']['name'] != ''){
                $upload = new UploadFile();
                $upload->set('default_dir',ATTACH_MOBILE.'/sliders');

                $result = $upload->upfile('link_pic');
                if ($result){
                    $_POST['link_pic'] = $upload->file_name;
                }else {
                    showMessage($upload->error);
                }
            }

            $insert_array = array();
            $insert_array['gc_id'] = trim($_POST['link_sliders']);
            $insert_array['link'] = trim($_POST['link']);
            $insert_array['gc_thumb'] = trim($_POST['link_pic']);

            $result = $model_link->add($insert_array);
            if ($result){
                $url = array(
                    array(
                        'url'=>'index.php?act=mb_sliders&op=mb_sliders_add',
                        'msg'=>$lang['link_add_again'],
                    ),
                    array(
                        'url'=>'index.php?act=mb_sliders&op=mb_sliders_list',
                        'msg'=>$lang['link_add_back_to_list'],
                    )
                );
                showMessage($lang['link_add_succ'],$url);
            }else {
                showMessage($lang['link_add_fail']);
            }
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_sliders.add');
    }

    /**
     * 编辑
     */
    public function mb_sliders_editOp(){
        $lang   = Language::getLangContent();
        $model_link = Model('mb_sliders');
        if ($_POST['form_submit'] == 'ok'){

            /**
             * 上传图片
             */
            if ($_FILES['link_pic']['name'] != ''){
                $upload = new UploadFile();
                $upload->set('default_dir',ATTACH_MOBILE.'/sliders');

                $result = $upload->upfile('link_pic');
                if ($result){
                    $_POST['gc_thumb'] = $upload->file_name;
                }else {
                    showMessage($upload->error);
                }
            }
            $link_array = $model_link->getOneLink(intval($_POST['gc_id']));
            $update_array = array();
            $update_array['gc_id'] = intval($_POST['gc_id']);
            $update_array['link'] = trim($_POST['link']);
            if ($_POST['gc_thumb']){
                $update_array['gc_thumb'] = $_POST['gc_thumb'];
            }
            $result = $model_link->updates($update_array);
            if ($result){
                /**
                 * 删除图片
                 */
                if (!empty($_POST['gc_thumb']) && !empty($link_array['gc_thumb'])){
                    @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$link_array['gc_thumb']);
                }
                $url = array(
                    array(
                        'url'=>'index.php?act=mb_sliders&op=mb_sliders_edit&gc_id='.intval($_POST['gc_id']),
                        'msg'=>$lang['link_edit_again']
                    ),
                    array(
                        'url'=>'index.php?act=mb_sliders&op=mb_sliders_list',
                        'msg'=>$lang['link_add_back_to_list'],
                    )
                );
                showMessage($lang['link_edit_succ'],$url);
            }else {
                showMessage($lang['link_edit_fail']);
            }
        }

        $link_array = $model_link->getOneLink(intval($_GET['gc_id']));
        if (empty($link_array)){
            showMessage($lang['wrong_argument']);
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        Tpl::output('link_array',$link_array);
        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_sliders.edit');
    }
    /**
     * ajax操作
     */
    public function ajaxOp(){
        switch ($_GET['branch']){
            /**
             * 合作伙伴 排序
             */
            case 'link_sort':
                $model_link = Model('link');
                $update_array = array();
                $update_array[$_GET['column']] = trim($_GET['value']);
                $result = $model_link->where(array('link_id'=>intval($_GET['id'])))->update($update_array);

                echo 'true';exit;
                break;
        }
    }

    /**
     *
     */
    public function mb_top_ad_listOp(){
        $lang   = Language::getLangContent();
        $model_link = Model('adv');
        /**
         * 删除
         */
        if ($_POST['form_submit'] == 'ok'){
            if (is_array($_POST['del_id']) && !empty($_POST['del_id'])){
                foreach ($_POST['del_id'] as $k => $v){
                    /**
                     * 删除图片
                     */
                    $v = intval($v);
                    $tmp = $model_link->getOneLink($v);
                    if (!empty($tmp['gc_thumb'])){
                        @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$tmp['gc_thumb']);
                    }
                    unset($tmp);
                    $model_link->del($v);
                }
                showMessage($lang['link_index_del_succ']);
            }else {
                showMessage($lang['link_index_choose_del']);
            }
        }

        $link_list = $model_link->getList(array('ap_id'=>101));
        /**
         * 整理图片链接
         */
        if (is_array($link_list)){
            foreach ($link_list as $k => $v){
                if (!empty($v['gc_thumb'])){
                    $link_list[$k]['gc_thumb'] = UPLOAD_SITE_URL.'/'.ATTACH_MOBILE.'/sliders'.'/'.$v['gc_thumb'];
                }
            }
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        $this->show_menu('mb_top_ad_list');

        Tpl::output('link_list',$link_list);
        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_adv.index');
    }


    public function get_adv_xmlOp(){
        $lang = Language::getLangContent();
        $adv  = Model('adv');
        $condition  = array();
        $condition['ap_id'] = intval($_GET['ap_id']);
        if ($_POST['query'] != '' && in_array($_POST['qtype'],array('adv_title'))) {
            $condition[$_POST['qtype']] = $_POST['query'];
        }
        $sort_fields = array('ap_id','adv_start_date','adv_end_date');
        if ($_POST['sortorder'] != '' && in_array($_POST['sortname'],$sort_fields)) {
            $order = $_POST['sortname'].' '.$_POST['sortorder'];
        }
        $condition['is_allow'] = '1';
        $page = new Page();
        $page->setEachNum($_POST['rp']);
        $page->setStyle('admin');
        $adv_list  = $adv->getList($condition,$page,'',$order);

        $data = array();
        $data['now_page'] = $page->get('now_page');
        $data['total_num'] = $page->get('total_num');
        $Positions = array('1'=>'顶部广告','2'=>'Banner广告');
        foreach ((array)$adv_list as $k => $adv_info) {
            $adv_data = unserialize($adv_info['adv_content']);
            $list = array();$operation_detail = '';
            $list['operation'] = "<a class='btn red' onclick=\"fg_delete({$adv_info['adv_id']})\"><i class='fa fa-trash-o'></i>删除</a><a class='btn blue' href='index.php?act=mb_sliders&op=adv_edit&adv_id={$adv_info['adv_id']}'><i class='fa fa-pencil-square-o'></i>编辑</a>";
            $list['adv_title'] = $adv_info['adv_title'];
            $list['position'] = $Positions[$adv_info['position']];
            $img = UPLOAD_SITE_URL.DS.ATTACH_ADV.DS.$adv_data['adv_pic'];
            $list['img'] =  <<<EOB
<a href="javascript:;" class="pic-thumb-tip" onMouseOut="toolTip()" onMouseOver="toolTip('<img src=\'{$img}\'>')">
<i class='fa fa-picture-o'></i></a>
EOB;
            $list['url'] = $adv_data['adv_pic_url'];

            $list['adv_start_date'] = date('Y-m-d',$adv_info['adv_start_date']);
            $list['adv_end_date'] = date('Y-m-d',$adv_info['adv_end_date']);
            $data['list'][$adv_info['adv_id']] = $list;
        }
        exit(Tpl::flexigridXML($data));
    }

    /**
     *
     * 管理员添加广告
     */
    public function adv_addOp(){
        if(!chksubmit()){
            Language::read('adv');
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_adv.add');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $validate_arr = array();
            $validate_arr[] = array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['adv_can_not_null']);
            $validate_arr[] = array("input"=>$_POST["aptype_hidden"], "require"=>"true", "message"=>$lang['must_select_ap']);
            $validate_arr[] = array("input"=>$_POST["adv_start_time"], "require"=>"true", "message"=>$lang['must_select_start_time']);
            $validate_arr[] = array("input"=>$_POST["adv_end_time"], "require"=>"true", "message"=>$lang['must_select_end_time']);
            if ($_POST["aptype_hidden"] == '1'){
                //文字广告
                $validate_arr[] = array("input"=>$_POST["adv_word"], "require"=>"true", "message"=>$lang['textadv_null_error']);
            }elseif ($_POST["aptype_hidden"] == '3'){
                //flash广告
                $validate_arr[] = array("input"=>$_FILES['flash_swf']['name'], "require"=>"true", "message"=>$lang['flashadv_null_error']);
            }else {
                //图片广告
                $validate_arr[] = array("input"=>$_FILES['adv_pic']['name'], "require"=>"true", "message"=>$lang['picadv_null_error']);
            }
            $obj_validate->validateparam = $validate_arr;
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $insert_array['adv_title']       = trim($_POST['adv_name']);
                $insert_array['ap_id']           = 101;
                $insert_array['position']       = (int)$_POST['position'];
                $insert_array['adv_start_date']  = $this->getunixtime($_POST['adv_start_time']);
                $insert_array['adv_end_date']    = $this->getunixtime($_POST['adv_end_time']);
                $insert_array['is_allow']        = '1';
                /**
                 * 建立文字广告信息的入库数组
                 */
                //判断页面编码确定汉字所占字节数
                switch (CHARSET){
                    case 'UTF-8':
                        $charrate = 3;
                        break;
                    case 'GBK':
                        $charrate = 2;
                        break;
                }
                //图片广告
                if($_POST['aptype_hidden'] == '0'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $result = $upload->upfile('adv_pic');
                    if (!$result){
                        showMessage($upload->error,'','','error');
                    }
                    $ac = array(
                        'adv_pic'     =>$upload->file_name,
                        'adv_pic_url' =>trim($_POST['adv_pic_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //文字广告
                if($_POST['aptype_hidden'] == '1'){
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //建立Flash广告信息的入库数组
                if($_POST['aptype_hidden'] == '3'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $upload->upfile('flash_swf');
                    $ac = array(
                        'flash_swf'  =>$upload->file_name,
                        'flash_url'  =>trim($_POST['flash_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //广告信息入库
                $result = $adv->adv_add($insert_array);
                //更新相应广告位所拥有的广告数量
                $condition['ap_id'] = intval($_POST['ap_id']);
                $ap_list = $adv->getApList($condition);
                $ap_list = $ap_list['0'];
                $adv_num = $ap_list['adv_num'];
                $param['ap_id']   = intval($_POST['ap_id']);
                $param['adv_num'] = $adv_num+1;
                $result2 = $adv->ap_update($param);

                if ($result&&$result2){
                    $this->log(L('adv_add_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_add_succ'],'index.php?act=mb_sliders&op=mb_top_ad_list&ap_id='.$_POST['ap_id']);
                }else {
                    showMessage($lang['adv_add_fail'],'index.php?act=mb_sliders&op=mb_top_ad_list&ap_id='.$_POST['ap_id']);
                }
            }
        }
    }

    /**
     *
     * 修改广告
     */
    public function adv_editOp(){
        if (empty($_GET['adv_id'])) {
            showMessage('参数错误');
        }
        Language::read('adv');
        if($_POST['form_submit'] != 'ok'){
            $adv  = Model('adv');
            $condition['adv_id'] = intval($_GET['adv_id']);
            $adv_list = $adv->getList($condition);
            Tpl::output('ref_url',getReferer());
            Tpl::output('adv_list',$adv_list);
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_adv.edit');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['ap_can_not_null']),
                array("input"=>$_POST["adv_start_date"], "require"=>"true","message"=>$lang['must_select_start_time']),
                array("input"=>$_POST["adv_end_date"], "require"=>"true", "message"=>$lang['must_select_end_time'])
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $param['adv_id']         = intval($_GET['adv_id']);
                $param['adv_title']      = trim($_POST['adv_name']);
                $param['adv_start_date'] = $this->getunixtime(trim($_POST['adv_start_date']));
                $param['adv_end_date']   = $this->getunixtime(trim($_POST['adv_end_date']));
                /**
                 * 建立图片广告信息的入库数组
                 */
                if($_POST['mark'] == '0'){
                    if($_FILES['adv_pic']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('adv_pic');
                        if (!$result){
                            showMessage($upload->error,'','','error');
                        }
                        $ac = array(
                            'adv_pic'     =>$upload->file_name,
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'adv_pic'     =>trim($_POST['pic_ori']),
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                /**
                 * 建立文字广告信息的入库数组
                 */
                if($_POST['mark'] == '1'){
                    //判断页面编码确定汉字所占字节数
                    switch (CHARSET){
                        case 'UTF-8':
                            $charrate = 3;
                            break;
                        case 'GBK':
                            $charrate = 2;
                            break;
                    }
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $param['adv_content'] = $ac;
                }
                /**
                 * 建立Flash广告信息的入库数组
                 */
                if($_POST['mark'] == '3'){
                    if($_FILES['flash_swf']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('flash_swf');
                        $ac = array(
                            'flash_swf'  =>$upload->file_name,
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'flash_swf'  =>trim($_POST['flash_ori']),
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                $result = $adv->updates($param);
                $url = array();
                if ($result){
                    $url = array(
                        array(
                            'url'=>trim($_POST['ref_url']),
                            'msg'=>$lang['goback_ap_manage'],
                        )
                    );
                    $this->log(L('adv_change_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_change_succ'],$url);
                }else {
                    showMessage($lang['adv_change_fail'],$url);
                }
            }
        }
    }

    /**
     *
     */
    public function mb_brand_listOp(){
        $lang   = Language::getLangContent();
        $model_link = Model('adv');
        /**
         * 删除
         */
        if ($_POST['form_submit'] == 'ok'){
            if (is_array($_POST['del_id']) && !empty($_POST['del_id'])){
                foreach ($_POST['del_id'] as $k => $v){
                    /**
                     * 删除图片
                     */
                    $v = intval($v);
                    $tmp = $model_link->getOneLink($v);
                    if (!empty($tmp['gc_thumb'])){
                        @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$tmp['gc_thumb']);
                    }
                    unset($tmp);
                    $model_link->del($v);
                }
                showMessage($lang['link_index_del_succ']);
            }else {
                showMessage($lang['link_index_choose_del']);
            }
        }

        $link_list = $model_link->getList(array('ap_id'=>103));
        /**
         * 整理图片链接
         */
        if (is_array($link_list)){
            foreach ($link_list as $k => $v){
                if (!empty($v['gc_thumb'])){
                    $link_list[$k]['gc_thumb'] = UPLOAD_SITE_URL.'/'.ATTACH_MOBILE.'/sliders'.'/'.$v['gc_thumb'];
                }
            }
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        $this->show_menu('mb_brand_list');

        Tpl::output('link_list',$link_list);
        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_brand.index');
    }


    public function get_brand_xmlOp(){
        $lang = Language::getLangContent();
        $adv  = Model('adv');
        $condition  = array();
        $condition['ap_id'] = intval($_GET['ap_id']);
        if ($_POST['query'] != '' && in_array($_POST['qtype'],array('adv_title'))) {
            $condition[$_POST['qtype']] = $_POST['query'];
        }
        $sort_fields = array('ap_id','adv_start_date','adv_end_date');
        if ($_POST['sortorder'] != '' && in_array($_POST['sortname'],$sort_fields)) {
            $order = $_POST['sortname'].' '.$_POST['sortorder'];
        }
        $condition['is_allow'] = '1';
        $page = new Page();
        $page->setEachNum($_POST['rp']);
        $page->setStyle('admin');
        $adv_list  = $adv->getList($condition,$page,'',$order);

        $data = array();
        $data['now_page'] = $page->get('now_page');
        $data['total_num'] = $page->get('total_num');

        foreach ((array)$adv_list as $k => $adv_info) {
            $adv_data = unserialize($adv_info['adv_content']);
            $list = array();$operation_detail = '';
            $list['operation'] = "<a class='btn red' onclick=\"fg_delete({$adv_info['adv_id']})\"><i class='fa fa-trash-o'></i>删除</a><a class='btn blue' href='index.php?act=mb_sliders&op=brand_edit&adv_id={$adv_info['adv_id']}'><i class='fa fa-pencil-square-o'></i>编辑</a>";
            $list['adv_title'] = $adv_info['adv_title'];
            $list['discount'] = '全场<font style="color:red">'.$adv_info['buy_style'].'</font>折起';
            $img = UPLOAD_SITE_URL.DS.ATTACH_ADV.DS.$adv_data['adv_pic'];
            $list['img'] =  <<<EOB
<a href="javascript:;" class="pic-thumb-tip" onMouseOut="toolTip()" onMouseOver="toolTip('<img src=\'{$img}\'>')">
<i class='fa fa-picture-o'></i></a>
EOB;
            $list['url'] = $adv_data['adv_pic_url'];

            $list['adv_start_date'] = date('Y-m-d',$adv_info['adv_start_date']);
            $list['adv_end_date'] = date('Y-m-d',$adv_info['adv_end_date']);
            $data['list'][$adv_info['adv_id']] = $list;
        }
        exit(Tpl::flexigridXML($data));
    }

    /**
     *
     * 管理员添加广告
     */
    public function brand_addOp(){
        if(!chksubmit()){
            Language::read('adv');
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_brand.add');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $validate_arr = array();
            $validate_arr[] = array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['adv_can_not_null']);
            $validate_arr[] = array("input"=>$_POST["aptype_hidden"], "require"=>"true", "message"=>$lang['must_select_ap']);
            $validate_arr[] = array("input"=>$_POST["adv_start_time"], "require"=>"true", "message"=>$lang['must_select_start_time']);
            $validate_arr[] = array("input"=>$_POST["adv_end_time"], "require"=>"true", "message"=>$lang['must_select_end_time']);
            if ($_POST["aptype_hidden"] == '1'){
                //文字广告
                $validate_arr[] = array("input"=>$_POST["adv_word"], "require"=>"true", "message"=>$lang['textadv_null_error']);
            }elseif ($_POST["aptype_hidden"] == '3'){
                //flash广告
                $validate_arr[] = array("input"=>$_FILES['flash_swf']['name'], "require"=>"true", "message"=>$lang['flashadv_null_error']);
            }else {
                //图片广告
                $validate_arr[] = array("input"=>$_FILES['adv_pic']['name'], "require"=>"true", "message"=>$lang['picadv_null_error']);
            }
            $obj_validate->validateparam = $validate_arr;
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $insert_array['adv_title']       = trim($_POST['adv_name']);
                $insert_array['ap_id']           = 103;
                $insert_array['buy_style']       = $_POST['buy_style'];
                $insert_array['adv_start_date']  = $this->getunixtime($_POST['adv_start_time']);
                $insert_array['adv_end_date']    = $this->getunixtime($_POST['adv_end_time']);
                $insert_array['is_allow']        = '1';
                /**
                 * 建立文字广告信息的入库数组
                 */
                //判断页面编码确定汉字所占字节数
                switch (CHARSET){
                    case 'UTF-8':
                        $charrate = 3;
                        break;
                    case 'GBK':
                        $charrate = 2;
                        break;
                }
                //图片广告
                if($_POST['aptype_hidden'] == '0'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $result = $upload->upfile('adv_pic');
                    if (!$result){
                        showMessage($upload->error,'','','error');
                    }
                    $ac = array(
                        'adv_pic'     =>$upload->file_name,
                        'adv_pic_url' =>trim($_POST['adv_pic_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //文字广告
                if($_POST['aptype_hidden'] == '1'){
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //建立Flash广告信息的入库数组
                if($_POST['aptype_hidden'] == '3'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $upload->upfile('flash_swf');
                    $ac = array(
                        'flash_swf'  =>$upload->file_name,
                        'flash_url'  =>trim($_POST['flash_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //广告信息入库
                $result = $adv->adv_add($insert_array);
                //更新相应广告位所拥有的广告数量
                $condition['ap_id'] = intval($_POST['ap_id']);
                $ap_list = $adv->getApList($condition);
                $ap_list = $ap_list['0'];
                $adv_num = $ap_list['adv_num'];
                $param['ap_id']   = intval($_POST['ap_id']);
                $param['adv_num'] = $adv_num+1;
                $result2 = $adv->ap_update($param);

                if ($result&&$result2){
                    $this->log(L('adv_add_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_add_succ'],'index.php?act=mb_sliders&op=mb_brand_list&ap_id='.$_POST['ap_id']);
                }else {
                    showMessage($lang['adv_add_fail'],'index.php?act=mb_sliders&op=mb_brand_list&ap_id='.$_POST['ap_id']);
                }
            }
        }
    }

    /**
     *
     * 修改广告
     */
    public function brand_editOp(){
        if (empty($_GET['adv_id'])) {
            showMessage('参数错误');
        }
        Language::read('adv');
        if($_POST['form_submit'] != 'ok'){
            $adv  = Model('adv');
            $condition['adv_id'] = intval($_GET['adv_id']);
            $adv_list = $adv->getList($condition);
            Tpl::output('ref_url',getReferer());
            Tpl::output('adv_list',$adv_list);
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_brand.edit');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['ap_can_not_null']),
                array("input"=>$_POST["adv_start_date"], "require"=>"true","message"=>$lang['must_select_start_time']),
                array("input"=>$_POST["adv_end_date"], "require"=>"true", "message"=>$lang['must_select_end_time'])
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $param['adv_id']         = intval($_GET['adv_id']);
                $param['adv_title']      = trim($_POST['adv_name']);
                $param['adv_start_date'] = $this->getunixtime(trim($_POST['adv_start_date']));
                $param['adv_end_date']   = $this->getunixtime(trim($_POST['adv_end_date']));
                /**
                 * 建立图片广告信息的入库数组
                 */
                if($_POST['mark'] == '0'){
                    if($_FILES['adv_pic']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('adv_pic');
                        if (!$result){
                            showMessage($upload->error,'','','error');
                        }
                        $ac = array(
                            'adv_pic'     =>$upload->file_name,
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'adv_pic'     =>trim($_POST['pic_ori']),
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                /**
                 * 建立文字广告信息的入库数组
                 */
                if($_POST['mark'] == '1'){
                    //判断页面编码确定汉字所占字节数
                    switch (CHARSET){
                        case 'UTF-8':
                            $charrate = 3;
                            break;
                        case 'GBK':
                            $charrate = 2;
                            break;
                    }
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $param['adv_content'] = $ac;
                }
                /**
                 * 建立Flash广告信息的入库数组
                 */
                if($_POST['mark'] == '3'){
                    if($_FILES['flash_swf']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('flash_swf');
                        $ac = array(
                            'flash_swf'  =>$upload->file_name,
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'flash_swf'  =>trim($_POST['flash_ori']),
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                $result = $adv->updates($param);
                $url = array();
                if ($result){
                    $url = array(
                        array(
                            'url'=>trim($_POST['ref_url']),
                            'msg'=>$lang['goback_ap_manage'],
                        )
                    );
                    $this->log(L('adv_change_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_change_succ'],$url);
                }else {
                    showMessage($lang['adv_change_fail'],$url);
                }
            }
        }
    }

    /**
     *
     */
    public function mb_product_listOp(){
        $lang   = Language::getLangContent();
        $model_link = Model('adv');
        /**
         * 删除
         */
        if ($_POST['form_submit'] == 'ok'){
            if (is_array($_POST['del_id']) && !empty($_POST['del_id'])){
                foreach ($_POST['del_id'] as $k => $v){
                    /**
                     * 删除图片
                     */
                    $v = intval($v);
                    $tmp = $model_link->getOneLink($v);
                    if (!empty($tmp['gc_thumb'])){
                        @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/sliders/'.$tmp['gc_thumb']);
                    }
                    unset($tmp);
                    $model_link->del($v);
                }
                showMessage($lang['link_index_del_succ']);
            }else {
                showMessage($lang['link_index_choose_del']);
            }
        }

        $link_list = $model_link->getList(array('ap_id'=>105));
        /**
         * 整理图片链接
         */
        if (is_array($link_list)){
            foreach ($link_list as $k => $v){
                if (!empty($v['gc_thumb'])){
                    $link_list[$k]['gc_thumb'] = UPLOAD_SITE_URL.'/'.ATTACH_MOBILE.'/sliders'.'/'.$v['gc_thumb'];
                }
            }
        }

        /**
         * 商品分类
         */
        $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
        Tpl::output('goods_class',$goods_class);

        $this->show_menu('mb_product_list');

        Tpl::output('link_list',$link_list);
        Tpl::setDirquna('mobile');
        Tpl::showpage('mb_product.index');
    }


    public function get_product_xmlOp(){
        $lang = Language::getLangContent();
        $adv  = Model('adv');
        $condition  = array();
        $condition['ap_id'] = intval($_GET['ap_id']);
        if ($_POST['query'] != '' && in_array($_POST['qtype'],array('adv_title'))) {
            $condition[$_POST['qtype']] = $_POST['query'];
        }
        $sort_fields = array('ap_id','adv_start_date','adv_end_date');
        if ($_POST['sortorder'] != '' && in_array($_POST['sortname'],$sort_fields)) {
            $order = $_POST['sortname'].' '.$_POST['sortorder'];
        }
        $condition['is_allow'] = '1';
        $page = new Page();
        $page->setEachNum($_POST['rp']);
        $page->setStyle('admin');
        $adv_list  = $adv->getList($condition,$page,'',$order);

        $data = array();
        $data['now_page'] = $page->get('now_page');
        $data['total_num'] = $page->get('total_num');

        $Positions = array('1'=>'黄金专区','2'=>'白银专区','3'=>'铂金专区','4'=>'珠宝专区');
        foreach ((array)$adv_list as $k => $adv_info) {
            $adv_data = unserialize($adv_info['adv_content']);
            $list = array();$operation_detail = '';
            $list['operation'] = "<a class='btn red' onclick=\"fg_delete({$adv_info['adv_id']})\"><i class='fa fa-trash-o'></i>删除</a><a class='btn blue' href='index.php?act=mb_sliders&op=product_edit&adv_id={$adv_info['adv_id']}'><i class='fa fa-pencil-square-o'></i>编辑</a>";
            $list['adv_title'] = $adv_info['adv_title'];
            $list['position'] = $Positions[$adv_info['position']];
            $img = UPLOAD_SITE_URL.DS.ATTACH_ADV.DS.$adv_data['adv_pic'];
            $list['img'] =  <<<EOB
<a href="javascript:;" class="pic-thumb-tip" onMouseOut="toolTip()" onMouseOver="toolTip('<img src=\'{$img}\'>')">
<i class='fa fa-picture-o'></i></a>
EOB;
            $list['url'] = $adv_data['adv_pic_url'];

            $list['adv_start_date'] = date('Y-m-d',$adv_info['adv_start_date']);
            $list['adv_end_date'] = date('Y-m-d',$adv_info['adv_end_date']);
            $data['list'][$adv_info['adv_id']] = $list;
        }
        exit(Tpl::flexigridXML($data));
    }

    /**
     *
     * 管理员添加广告
     */
    public function product_addOp(){
        if(!chksubmit()){
            Language::read('adv');
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_product.add');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $validate_arr = array();
            $validate_arr[] = array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['adv_can_not_null']);
            $validate_arr[] = array("input"=>$_POST["aptype_hidden"], "require"=>"true", "message"=>$lang['must_select_ap']);
            $validate_arr[] = array("input"=>$_POST["adv_start_time"], "require"=>"true", "message"=>$lang['must_select_start_time']);
            $validate_arr[] = array("input"=>$_POST["adv_end_time"], "require"=>"true", "message"=>$lang['must_select_end_time']);
            if ($_POST["aptype_hidden"] == '1'){
                //文字广告
                $validate_arr[] = array("input"=>$_POST["adv_word"], "require"=>"true", "message"=>$lang['textadv_null_error']);
            }elseif ($_POST["aptype_hidden"] == '3'){
                //flash广告
                $validate_arr[] = array("input"=>$_FILES['flash_swf']['name'], "require"=>"true", "message"=>$lang['flashadv_null_error']);
            }else {
                //图片广告
                $validate_arr[] = array("input"=>$_FILES['adv_pic']['name'], "require"=>"true", "message"=>$lang['picadv_null_error']);
            }
            $obj_validate->validateparam = $validate_arr;
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $insert_array['adv_title']       = trim($_POST['adv_name']);
                $insert_array['ap_id']           = 105;

                $insert_array['position']       = $_POST['position'];
                $insert_array['adv_start_date']  = $this->getunixtime($_POST['adv_start_time']);
                $insert_array['adv_end_date']    = $this->getunixtime($_POST['adv_end_time']);
                $insert_array['is_allow']        = '1';
                /**
                 * 建立文字广告信息的入库数组
                 */
                //判断页面编码确定汉字所占字节数
                switch (CHARSET){
                    case 'UTF-8':
                        $charrate = 3;
                        break;
                    case 'GBK':
                        $charrate = 2;
                        break;
                }
                //图片广告
                if($_POST['aptype_hidden'] == '0'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $result = $upload->upfile('adv_pic');
                    if (!$result){
                        showMessage($upload->error,'','','error');
                    }
                    $ac = array(
                        'adv_pic'     =>$upload->file_name,
                        'adv_pic_url' =>trim($_POST['adv_pic_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //文字广告
                if($_POST['aptype_hidden'] == '1'){
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //建立Flash广告信息的入库数组
                if($_POST['aptype_hidden'] == '3'){
                    $upload->set('default_dir',ATTACH_ADV);
                    $upload->upfile('flash_swf');
                    $ac = array(
                        'flash_swf'  =>$upload->file_name,
                        'flash_url'  =>trim($_POST['flash_url'])
                    );
                    $ac = serialize($ac);
                    $insert_array['adv_content'] = $ac;
                }
                //广告信息入库
                $result = $adv->adv_add($insert_array);
                //更新相应广告位所拥有的广告数量
                $condition['ap_id'] = intval($_POST['ap_id']);
                $ap_list = $adv->getApList($condition);
                $ap_list = $ap_list['0'];
                $adv_num = $ap_list['adv_num'];
                $param['ap_id']   = intval($_POST['ap_id']);
                $param['adv_num'] = $adv_num+1;
                $result2 = $adv->ap_update($param);

                if ($result&&$result2){
                    $this->log(L('adv_add_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_add_succ'],'index.php?act=mb_sliders&op=mb_product_list&ap_id='.$_POST['ap_id']);
                }else {
                    showMessage($lang['adv_add_fail'],'index.php?act=mb_sliders&op=mb_product_list&ap_id='.$_POST['ap_id']);
                }
            }
        }
    }

    /**
     *
     * 修改广告
     */
    public function product_editOp(){
        if (empty($_GET['adv_id'])) {
            showMessage('参数错误');
        }
        Language::read('adv');
        if($_POST['form_submit'] != 'ok'){
            $adv  = Model('adv');
            $condition['adv_id'] = intval($_GET['adv_id']);
            $adv_list = $adv->getList($condition);
            Tpl::output('ref_url',getReferer());
            Tpl::output('adv_list',$adv_list);
            Tpl::setDirquna('mobile');
            Tpl::showpage('mb_product.edit');
        }else{
            $lang = Language::getLangContent();
            $adv  = Model('adv');
            $upload     = new UploadFile();
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["adv_name"], "require"=>"true", "message"=>$lang['ap_can_not_null']),
                array("input"=>$_POST["adv_start_date"], "require"=>"true","message"=>$lang['must_select_start_time']),
                array("input"=>$_POST["adv_end_date"], "require"=>"true", "message"=>$lang['must_select_end_time'])
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $param['adv_id']         = intval($_GET['adv_id']);
                $param['adv_title']      = trim($_POST['adv_name']);
                $param['adv_start_date'] = $this->getunixtime(trim($_POST['adv_start_date']));
                $param['adv_end_date']   = $this->getunixtime(trim($_POST['adv_end_date']));
                /**
                 * 建立图片广告信息的入库数组
                 */
                if($_POST['mark'] == '0'){
                    if($_FILES['adv_pic']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('adv_pic');
                        if (!$result){
                            showMessage($upload->error,'','','error');
                        }
                        $ac = array(
                            'adv_pic'     =>$upload->file_name,
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'adv_pic'     =>trim($_POST['pic_ori']),
                            'adv_pic_url' =>trim($_POST['adv_pic_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                /**
                 * 建立文字广告信息的入库数组
                 */
                if($_POST['mark'] == '1'){
                    //判断页面编码确定汉字所占字节数
                    switch (CHARSET){
                        case 'UTF-8':
                            $charrate = 3;
                            break;
                        case 'GBK':
                            $charrate = 2;
                            break;
                    }
                    if(strlen($_POST['adv_word'])>($_POST['adv_word_len']*$charrate)){
                        $error = $lang['wordadv_toolong'];
                        showMessage($error);die;
                    }
                    $ac = array(
                        'adv_word'    =>trim($_POST['adv_word']),
                        'adv_word_url'=>trim($_POST['adv_word_url'])
                    );
                    $ac = serialize($ac);
                    $param['adv_content'] = $ac;
                }
                /**
                 * 建立Flash广告信息的入库数组
                 */
                if($_POST['mark'] == '3'){
                    if($_FILES['flash_swf']['name'] != ''){
                        $upload->set('default_dir',ATTACH_ADV);
                        $result = $upload->upfile('flash_swf');
                        $ac = array(
                            'flash_swf'  =>$upload->file_name,
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }else{
                        $ac = array(
                            'flash_swf'  =>trim($_POST['flash_ori']),
                            'flash_url'  =>trim($_POST['flash_url'])
                        );
                        $ac = serialize($ac);
                        $param['adv_content'] = $ac;
                    }
                }
                $result = $adv->updates($param);
                $url = array();
                if ($result){
                    $url = array(
                        array(
                            'url'=>trim($_POST['ref_url']),
                            'msg'=>$lang['goback_ap_manage'],
                        )
                    );
                    $this->log(L('adv_change_succ').'['.$_POST["adv_name"].']',null);
                    showMessage($lang['adv_change_succ'],$url);
                }else {
                    showMessage($lang['adv_change_fail'],$url);
                }
            }
        }
    }

    /**
     * 页面内导航菜单
     * @param string    $menu_key   当前导航的menu_key
     * @param array     $array      附加菜单
     * @return
     */
    private function show_menu($menu_key='') {
        $menu_array = array();
        if($menu_key == 'mb_sliders_list') {
            $menu_array[] = array('menu_key'=>'mb_sliders_list', 'menu_name'=>'首页幻灯片', 'menu_url'=>'javascript:;');
            $menu_array[] = array('menu_key'=>'mb_top_ad_list','menu_name'=>'手机版广告区', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_top_ad_list'));
            $menu_array[] = array('menu_key'=>'mb_brand_list','menu_name'=>'手机版首页品牌', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_brand_list'));
            $menu_array[] = array('menu_key'=>'mb_product_list','menu_name'=>'手机版首页产品', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_product_list'));
        }elseif($menu_key=='mb_top_ad_list') {
            $menu_array[] = array('menu_key'=>'mb_sliders_list', 'menu_name'=>'首页幻灯片', 'menu_url'=>urlAdminMobile('mb_sliders', 'index'));
            $menu_array[] = array('menu_key'=>'mb_top_ad_list','menu_name'=>'手机版广告区', 'menu_url'=>'javascript:;');
            $menu_array[] = array('menu_key'=>'mb_brand_list','menu_name'=>'手机版首页品牌', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_brand_list'));
            $menu_array[] = array('menu_key'=>'mb_product_list','menu_name'=>'手机版首页产品', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_product_list'));
        }elseif($menu_key=='mb_brand_list') {
            $menu_array[] = array('menu_key'=>'mb_sliders_list', 'menu_name'=>'首页幻灯片', 'menu_url'=>urlAdminMobile('mb_sliders', 'index'));
            $menu_array[] = array('menu_key'=>'mb_top_ad_list','menu_name'=>'手机版广告区', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_top_ad_list'));
            $menu_array[] = array('menu_key'=>'mb_brand_list','menu_name'=>'手机版首页品牌', 'menu_url'=>'javascript:;');
            $menu_array[] = array('menu_key'=>'mb_product_list','menu_name'=>'手机版首页产品', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_product_list'));
        }else{
            $menu_array[] = array('menu_key'=>'mb_sliders_list', 'menu_name'=>'首页幻灯片', 'menu_url'=>urlAdminMobile('mb_sliders', 'index'));
            $menu_array[] = array('menu_key'=>'mb_top_ad_list','menu_name'=>'手机版广告区', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_top_ad_list'));
            $menu_array[] = array('menu_key'=>'mb_brand_list','menu_name'=>'手机版首页品牌', 'menu_url'=>urlAdminMobile('mb_sliders', 'mb_brand_list'));
            $menu_array[] = array('menu_key'=>'mb_product_list','menu_name'=>'手机版首页产品', 'menu_url'=>'javascript:;');
        }
        if($menu_key == 'mb_sliders_list') {
            tpl::output('item_title', '首页幻灯片');
        } elseif($menu_key == 'mb_top_ad_list')  {
            tpl::output('item_title', '手机版广告区');
        }elseif($menu_key=='mb_brand_list'){
            tpl::output('item_title', '手机版首页品牌');
        }else{
            tpl::output('item_title', '手机版首页产品');
        }
        Tpl::output('menu', $menu_array);
        Tpl::output('menu_key', $menu_key);
    }
    /**
     *
     * 获取UNIX时间戳
     */
    public function getunixtime($time){
        $array     = explode("-", $time);
        $unix_time = mktime(0,0,0,$array[1],$array[2],$array[0]);
        return $unix_time;
    }
}
